namespace SimpleWebServices
{
    using System;
    using System.IO;
    using System.Runtime.Serialization.Formatters.Binary;
    using Xunit;

    public sealed class ArgumentInvalidGenericExceptionFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<ArgumentInvalidGenericException>()
                .DerivesFrom<ArgumentException>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .Serializable()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new ArgumentInvalidGenericException());
        }

        [Fact]
        public void ctor_string()
        {
            Assert.NotNull(new ArgumentInvalidGenericException("message"));
        }

        [Fact]
        public void ctor_stringEmpty()
        {
            Assert.NotNull(new ArgumentInvalidGenericException(string.Empty));
        }

        [Fact]
        public void ctor_stringNull()
        {
            Assert.NotNull(new ArgumentInvalidGenericException(null));
        }

        [Fact]
        public void ctor_string_Exception()
        {
            Assert.NotNull(new ArgumentInvalidGenericException("message", new Exception()));
        }

        [Fact]
        public void ctor_stringEmpty_Exception()
        {
            Assert.NotNull(new ArgumentInvalidGenericException(string.Empty, new Exception()));
        }

        [Fact]
        public void ctor_stringNull_Exception()
        {
            Assert.NotNull(new ArgumentInvalidGenericException(null, new Exception()));
        }

        [Fact]
        public void ctor_string_ExceptionNull()
        {
            Assert.NotNull(new ArgumentInvalidGenericException("message", null));
        }

        [Fact]
        public void ctor_SerializationInfo_StreamingContext()
        {
            ArgumentInvalidGenericException expected = new ArgumentInvalidGenericException("test");
            ArgumentInvalidGenericException actual = null;

            using (Stream stream = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(stream, new ArgumentInvalidGenericException("test"));
                stream.Position = 0;
                actual = (ArgumentInvalidGenericException)formatter.Deserialize(stream);
            }

            Assert.Equal<string>(expected.Message, actual.Message);
        }
    }
}